package com.tts.superstar;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.tts.superstar.View.BaseActivity;
import com.tts.superstar.fragment.HottestFragment;
import com.tts.superstar.fragment.NewestFragment;
import com.tts.superstar.fragment.PastFragment;
import com.tts.superstar.fragment.RegionFragment;

public class HuodongActivity extends BaseActivity {

    ImageView mIvFanhui;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_huodong);
        setFragment(new NewestFragment());

        Button button2 = (Button)findViewById(R.id.btn_hd2);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setFragment(new HottestFragment());
            }
        });

        Button button1 = (Button)findViewById(R.id.btn_hd1);
        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setFragment(new NewestFragment());
            }
        });



        Button button3 = (Button)findViewById(R.id.btn_hd3);
        button3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setFragment(new PastFragment());
            }
        });

        Button button4 = (Button)findViewById(R.id.btn_hd4);
        button4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setFragment(new RegionFragment());
            }
        });

        mIvFanhui = findViewById(R.id.iv_fanhui);
        mIvFanhui.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    void setFragment(Fragment fragment){
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.layout_frag,fragment);
        fragmentTransaction.commit();
    }
}
